package com.hzit.pay.center.service.impl;

import com.hzit.pay.center.mapper.NoticeInfoMapper;
import com.hzit.pay.center.model.NoticeInfo;
import com.hzit.pay.center.service.INoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class NoticeServiceImpl implements INoticeService {

    @Autowired
    private NoticeInfoMapper noticeInfoMapper;

    @Override
    public NoticeInfo queryBySerialNo(String paySerialNo) {

        return noticeInfoMapper.queryBySerialNo(paySerialNo);
    }

    @Override
    public NoticeInfo createNotice(String mchId,String paySerialNo,String status) {

        NoticeInfo noticeInfo = new NoticeInfo();

        Date date = new Date();
        noticeInfo.setMchId(mchId);
        noticeInfo.setNotifyCount(1);
        noticeInfo.setNotifyStatus(status);
        noticeInfo.setPaySerialNo(paySerialNo);
        noticeInfo.setCreateTime(date);
        noticeInfoMapper.insertSelective(noticeInfo);

        return null;
    }

    @Override
    public NoticeInfo updateNotice(NoticeInfo  noticeInfo) {

        NoticeInfo  record = new NoticeInfo();
        record.setId(noticeInfo.getId());
        record.setNotifyCount(noticeInfo.getNotifyCount());
        record.setNotifyStatus(noticeInfo.getNotifyStatus());
        record.setNotifySuccessTime(noticeInfo.getNotifySuccessTime());
        record.setUpdateTime(new Date());
        noticeInfoMapper.updateByPrimaryKeySelective(noticeInfo);

        return null;
    }
}
